/*
 * Description: performance registry controll utils
 */
#ifndef REGISTRY_UTILS_H
#define REGISTRY_UTILS_H
#include "Windows.h"
#include "singleton.h"
#include <string>
#include "performance/model/perf_info.h"

namespace PERF {
class RegistryUtils {
public:
    bool GetHKCU(HKEY &hKey);
    bool GetRegKey(const HKEY &hRoot, LPCTSTR subKeyName, HKEY &hKey);
    bool CreateRegKey(const HKEY &hKey, LPCSTR subKey, HKEY &hNewKey);
    bool GetRegEnumSize(const HKEY &hKey, DWORD &size, DWORD &maxSubKeyLen, DWORD &maxValueNameLen);
    bool GetRegItemKeyName(const HKEY &hKey, DWORD idx, LPSTR itemKeyName, DWORD &maxSubKeyLen);
    bool QueryRegValue(const HKEY &hRoot, LPCTSTR subKey, LPCTSTR itemKey, OfficeAddInValue &value);
    bool SetRegValue(const HKEY &hRoot, LPCTSTR subKey, LPCTSTR itemKey, const OfficeAddInValue &value);
    bool QueryRegDWORD(const HKEY &hKey, LPCTSTR subKey, LPCTSTR itemKey, DWORD &itemValue);
    bool SetRegDWORD(const HKEY &hKey, LPCTSTR subKey, LPCTSTR itemKey, DWORD itemValue);
    bool QueryRegSZ(const HKEY &hKey, LPCTSTR subKey, LPCSTR itemKey, std::string &itemValue);
    bool SetRegSZ(const HKEY &hKey, LPCTSTR subKey, LPCSTR itemKey, const std::string &itemValue);
    bool DeleteRegKey(const HKEY &hKey, LPCSTR subKey);
    void SafeCloseHKey(HKEY &hHey);
};
#define REGISTRY_UTILS SingletonNew<PERF::RegistryUtils>::GetInstance()
}  // namespace PERF

#endif